/* eslint-disable max-classes-per-file */
import { JsonProperty, Serializable } from '@/plugins/reflect-metadata';

import { OrderStatusType } from '../const';
import CardOrderItem, { CardOrderDetailItem } from './CardOrderItem';

@Serializable()
export class CardOrderQuery {
  @JsonProperty('pageNum')
    pageNum: number = 1;

  @JsonProperty('pageSize')
    pageSize: number = 10;

  @JsonProperty('totalStatus')
    totalStatus: number = 0;

  get params() {
    return {
      pageNum: this.pageNum,
      pageSize: this.pageSize,
      totalStatus: OrderStatusType[this.totalStatus],
    };
  }
}

@Serializable()
export class CardOrderDetailList {
  @JsonProperty({ name: 'data', type: CardOrderDetailItem })
    items: CardOrderDetailItem[] = [];

  get total() {
    return this.items.length;
  }
}

@Serializable()
export default class CardOrderList {
  @JsonProperty({ name: 'rows', type: CardOrderItem })
    items: CardOrderItem[] = [];

  @JsonProperty('total')
    total: number = 0;
}
